<%@ page contentType="text/html;charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<html>
<head>
<title>系统配置管理</title>
<script type="text/javascript">
	var $grid;
	$(function() {
		$grid = $("#grid").datagrid($.extend(datagridOption, {
			url : "${ctx}/wx/mediaAsynInfo/dataGrid",
			columns : [ [ {
				field : 'ck',
				checkbox : true
			}, {
				field : 'app',
				title : '所属公众号',
				sortable : true,
				fomattor:function(value, index, row){
					return value.appName;
				}
			}, {
				field : 'media.title',
				title : '所属媒体',
				sortable : true
			}, {
				field : 'media.mediaType',
				title : '媒体类型',
				sortable : true
			}, {
				field : 'media.introduction',
				title : '媒体描述',
				sortable : true
			}, {
				field : 'mediaId',
				title : '媒体ID',
				sortable : true
			} ] ]
		}));

		$grid.datagrid('enableFilter', [ buildDGFilterYesOrNoFieldOptions($grid, 'enable') ]);

		fn_initComboNotId("mediaType", "mediaType", true);//媒体类型
		fn_initComboNotId("fileType", "fileType", false);//文件类型
		
		$("#add").click(function() {
			$("#fm").form("clear");
			$('#fm').form('load');

			$("#dlg").dialog("open").dialog("setTitle", "新增微信多媒体");
		});
		$("#edit").click(function() {
			var rowData = $grid.datagrid("getSelected");
			if (!rowData) {
				showInfo("您未选中行，无法编辑");
			} else {
				$("#dlg").dialog("open").dialog("setTitle", "编辑微信多媒体");
				$("#fm").form("clear");
				$("#fm").form("load", rowData);
				fn_setValueForComboBox("mediaType", rowData.mediaType, rowData.mediaType);
				fn_setValueForComboBox("fileType", rowData.fileType, rowData.fileType);
			}
		});
		$("#delete").click(function() {
			multiDeleteDataGrid($grid, "${ctx}/wx/media/multiDelete");
		});
		
		$("#excelExport").click(function() {
			var url = "${ctx}/wx/media/excelExport?" + $.param($grid.datagrid('options').queryParams);
			if ($grid.datagrid("options").filterRules) {
				url += "&filterRules=" + JSON.stringify($grid.datagrid("options").filterRules);
			}
			window.parent.location.href = url;
		});
	});
</script>
</head>

<body>
	<div data-options="region:'center',fit:true,border:false">
		<table id="grid">
		</table>
	</div>
	<div id="tt" class="easyui-toolbar">
		<shiro:hasPermission name="media:update">
			<a id="add" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-standard-add'">新增</a>
			<a id="edit" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-hamburg-pencil'">编辑</a>
		</shiro:hasPermission>
		<shiro:hasPermission name="media:delete">
			<a id="delete" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-hamburg-busy'">删除</a>
			<div class="dialog-tool-separator"></div>
		</shiro:hasPermission>
		<shiro:hasPermission name="media:export">
			<a id="excelExport" class="easyui-linkbutton" data-options="plain: true, iconCls: 'icon-standard-page-excel'">Excel导出</a>
		</shiro:hasPermission>
	</div>
	<shiro:hasPermission name="media:update">
		<div id="dlg" class="easyui-dialog" style="width: 610px; height: 280px; padding: 10px 20px"
			data-options="iconCls:'icon-save',resizable:true,modal:true, buttons:[
                    { text: '保存', iconCls: 'icon-ok', handler: function () { formSave('#fm', '#grid', '#dlg', '${ctx}/wx/media/update'); } },
                    { text: '取消', iconCls:'icon-cancel', handler: function () { $('#dlg').dialog('close'); } }
                ],closed:true">
			<form id="fm" method="post">
				<input type="hidden" name="id" />
				<table id="tbl">
					<tr>
						<td><label>媒体类型:</label></td>
						<td><input id="mediaType" name="mediaType"></td>
						<td><label>标题:</label></td>
						<td><input name="title" class="easyui-validatebox" data-options="required: true"></td>
					</tr>
					<tr>
						<td><label>描述:</label></td>
						<td><input name="introduction" class="easyui-validatebox"></td>
						<td><label>附件名称:</label></td>
						<td><input name="fileName" class="easyui-validatebox"></td>
					</tr>
					<tr>
						<td><label>保存路径:</label></td>
						<td><input name="filePath" class="easyui-validatebox"></td>
						<td><label>附件大小:</label></td>
						<td><input name="fileSize" class="easyui-validatebox"></td>
					</tr>
					<tr>
						<td><label>上传时间:</label></td>
						<td><input name="uploadTime" class="easyui-validatebox"></td>
						<td><label>最后下载时间:</label></td>
						<td><input name="lastDownloadTime" class="easyui-validatebox"></td>
					</tr>
					<tr>
						<td><label>文件类型:</label></td>
						<td><input name="fileType" id="fileType"></td>
						<td><label>上传者:</label></td>
						<td><input name="uploader" class="easyui-validatebox"></td>
					</tr>
				</table>

			</form>
		</div>
	</shiro:hasPermission>
</body>
</html>
